<?php

/**
 * XHTML_Style, xhtml_lib
 * 
 * This file contains the source code for the XHTML_Style class.
 * @author Fernando Jimenez Mocobono <fjmcool@gmail.com>
 * @version 0.1
 * @package xhtml_lib
 */

include_once "XHTML_I18n_Element.php";

/**
 * The XHTML_Style class is a handler for the style xhtml-strict tag as a part
 * of a xhtml-strict php-handler implementation.
 */
class XHTML_Style extends XHTML_I18n_Element {
    
    // xhtml attributes
    
    /**
     * Unique identifier for the xhtml-style-tag.
     * 
     * @var string
     */
    protected $id;
    
    /**
     * Content-type.
     *
     * @var string
     */
    protected $type;
    
    /**
     * Destination medium for the style information.
     * Valid values: screen, tty, tv, projection, handheld, print, braille, 
     * aural, all.
     *
     * @var string
     */
    protected $media;
    
    /**
     * Text to display in a tool tip.
     *
     * @var string
     */
    protected $title;
    

    //inner elements
    
    /**
     * Style definition text.
     * 
     * @var string
     */
    protected $text;
    
    
    // Methods
    
    /**
     * Constructs a XHTML_Style object with its required type.
     */
    function __construct($type)
    {
        $this->type = $type;
    }
    
    /**
     * Sets the unique identifier.
     *
     * @param string $id
     */
    function setId($id)
    {
        $this->id = $id;
    }
    
    /**
     * Gets the unique identifier.
     *
     * @return string
     */
    function getId()
    {
        return $this->id;
    }
    
    /**
     * Sets the content-type.
     *
     * @param string $type
     */
    function setType($type)
    {
        $this->type = $type;
    }
    
    /**
     * Gets the content-type.
     *
     * @return string
     */
    function getType()
    {
        return $this->type;
    }
    
    /**
     * Sets the destination medium for the style information.
     * Valid values: screen, tty, tv, projection, handheld, print, braille, 
     * aural, all.
     *
     * @param string $media
     */
    function setMedia($media)
    {
        $this->media = $media;
    }
    
    /**
     * Gets the destination medium for the style information.
     * Valid values: screen, tty, tv, projection, handheld, print, braille, 
     * aural, all.
     *
     * @return string
     */
    function getMedia()
    {
        return $this->media;
    }
    
    /**
     * Sets the text to display in a tool tip.
     *
     * @param string $title
     */
    function setTitle($title)
    {
        $this->title = $title;
    }
    
    /**
     * Gets the text to display in a tool tip.
     * 
     * @return string
     */
    function getTitle()
    {
        return $this->title;
    }
    
    /**
     * Sets the style definition text.
     * 
     * @param string
     */
    function setText($text)
    {
        $this->text = $text;
    }
    
    /**
     * Gets the style definition text.
     *
     * @return string
     */
    function getText()
    {
        return $this->text;
    }
    
    // Overriding the toString method for a proper implementation.
    
    /**
     * Returns the string representation for echoing the class atributes.
     *
     * @return string
     */
    function toString()
    {
        $auxString = "<style".parent::toString();
        
        /*
         * Additions of the style own attributes to the return string.
         */
        if (isset($this->id)) {
            $auxString = $auxString."id=\"".$this->id."\" ";
        }
        
        $auxString = $auxString."type=\"".$this->type."\" ";
        
        if (isset($this->media)) {
            $auxString = $auxString."media=\"".$this->media."\" ";
        }
        
        if (isset($this->title)) {
            $auxString = $auxString."title=\"".$this->title."\" ";
        }
        
        // DO NOT DELETE THE FOLLOWING LINE.
        // xml:space is a fixed attribute.
        $auxString = $auxString."xml:space=\"preserve\" >\n";
        
        /*
         * Additions of the inner elements of the style element to the return 
         * string.
         */
        $auxString = $auxString.$this->text."\n";
        
        $auxString = $auxString."</style>\n";
        
        return $auxString;
    }
    
}

?>